package com.gd.luxiaoyu;
import java.sql.*;

public class TestJdbc {
    public static void main(String args[]){
        PreparedStatement preparedStatement = getConnection();
        try {
            ResultSet resultSet= preparedStatement.executeQuery();

            while (resultSet.next()){
                System.out.println(resultSet.getObject(1));
                System.out.println(resultSet.getObject(2));
                System.out.println(resultSet.getObject(3));
                System.out.println(resultSet.getObject(4));
            }

        } catch (SQLException e) {
            e.printStackTrace();
        }

    }
    public static   PreparedStatement getConnection(){
        Connection connection = null;
        PreparedStatement pst = null;
        try {
            Class.forName("com.mysql.jdbc.Driver");//加载驱动

            connection = DriverManager.getConnection("jdbc:mysql://192.168.0.102:3306/universityproject","root","123456");
            pst = connection .prepareStatement("select  * from admin_table");
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (SQLException e) {
            e.printStackTrace();
        }

        return pst;

    }
}
